export default {

  unwatchMap: {},

  /**
   * 根据配置获取数据
   * @param setting 配置
   * @param params 参数
   * @param callback 回调
   * @param widget 组件
   */
  loadData(setting, params, callback, widget) {
    console.log('setting', setting);
    this.unwatchMap[widget.val.uuid] = widget.$watch('globalData.' + setting.dataKey, function (val) {
      console.log('$watch', 'globalData.' + setting.dataKey, val);
      widget.updateData(val);
    }, {
      deep: true,
      immediate: true
    });
  },

  destroy(widget) {
    let unwatch = this.unwatchMap[widget.val.uuid];
    if (unwatch) {
      unwatch();
    }
  }

}
